package com.springcloud.alibaba;

import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;

/**
 * @Author:RenPu
 * @Date: 2020/7/1 22:54
 * @Version: 1.0
 * @description:
 */


@SpringBootApplication
@EnableFeignClients
@EnableHystrix
public class ConsulHystrixMain9002 {

    public static void main(String[] args) {

        SpringApplication.run( ConsulHystrixMain9002.class,args );

    }

    /**
     * 配合dashborad可视化展示
     * @return
     */
    @Bean
    public ServletRegistrationBean getServlet(){
        HystrixMetricsStreamServlet hystrixMetricsProperties = new HystrixMetricsStreamServlet();
        ServletRegistrationBean servletServletRegistrationBean = new ServletRegistrationBean(hystrixMetricsProperties);

        servletServletRegistrationBean.setLoadOnStartup( 1 );
        servletServletRegistrationBean.addUrlMappings( "/hystrix.stream" );
        servletServletRegistrationBean.setName( "HystrixMetricsStreamServlet" );

        return servletServletRegistrationBean;


    }
}
